import unittest,time,random
from tools.HTMLTestRunner import HTMLTestRunner  # 从你的文件中把这个第三方模块导出来
from scripts.u_miaoce_login import TestCaseLogin
from app import Base_Dir

suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestCaseLogin))
# suite.addTest(unittest.makeSuite(TestHrm))

# HTMLTestRunner 内置了 TextTestRunner方法

# 定义生成的报告存放目录
file_dir = Base_Dir + r"/reports/"
# 定义报告名字

time_str = time.strftime('%Y-%m-%d-%H-%M-%S', time.localtime(time.time()))
rand_num = str(random.randint(10000, 99999))
name = time_str+rand_num
# 报告完整路径和名称
file_name = file_dir + name+'.html'

with open(file_name, "wb") as f:
    # 实例化HTMLTestRunenr对象，传入报告文件流f;  description: 对报告的描述，根据自己想法写
    rep = HTMLTestRunner(stream=f, title='测试报告', description='windows chrome')
    rep.run(suite)
